package com.shortvedio.content.api;

import com.shortvedio.base.context.BaseContext;
import com.shortvedio.base.model.Result;
import com.shortvedio.base.model.po.Favorites;
import com.shortvedio.content.service.FavoritesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/favorites")
public class FavoritesController {

    @Autowired
    private FavoritesService favoritesService;

    @PostMapping("/add_favorites")  //添加收藏夹
    public Result addFavotites(@RequestBody Favorites favorites){
        Long userId = BaseContext.getCurrentId();
        favorites.setUserId(userId);
        log.info("favorites:{}",favorites);
        Result result = favoritesService.addFavorites(favorites);
        return result;
    }

    @DeleteMapping("/delete_favorites")   //删除收藏夹
    public Result deleteFavorites(@RequestParam Long favoritesId){
        Long userId = BaseContext.getCurrentId();
        Result result = favoritesService.deleteFavorites(favoritesId, userId);
        return result;
    }

}
